package edu.kit.csl.pisa.datatypes;

/*
This file is part of the PISA Alignment Tool.

Copyright (C) 2013
Karlsruhe Institute of Technology
Cognitive Systems Lab (CSL)
Felix Stahlberg

PISA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PISA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PISA. If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * This dictionary is a dummy implementation for realizing the null-object
 * design pattern and for testing purposes. The translation function is the
 * identity, meaning the key equals its value all the time, and it does not
 * have to be added before.
 * 
 * @see edu.kit.csl.pisa.models.AlignmentModel#dumpParameter(String, Object[],
			Dictionary[])
 */
public class IdentityDictionary extends Dictionary {

	/**
	 * Null-object implementation. Nothing to do here.
	 */
	public IdentityDictionary() {
		;
	}

	/**
	 * Converts a string to an integer.
	 * 
	 * @param key the string to convert
	 * @return integer variable of this string
	 * @throws NumberFormatException
	 */
	@Override
	public int get(String key) {
		return Integer.parseInt(key);
	}

	/**
	 * Returns the given id as string.
	 * 
	 * @param id integer variable
	 * @return string representation of <code>id</code>
	 */
	@Override
	public String get(int id) {
		return "" + id;
	}

	/**
	 * Null-object implementation. Returns 1 unconditionally.
	 */
	@Override
	public int size() {
		return 1;
	}

	/**
	 * Null-object implementation. Nothing to clear hear.
	 */
	@Override
	public void clear() {
		;
	}
}
